package com.example.administrator.waitan.hot;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TabHost;

import com.example.administrator.waitan.R;
import com.example.administrator.waitan.hot.today.TodayFragment;
import com.example.administrator.waitan.hot.week.WeekFragment;

/**
 * Created by Administrator on 2016/1/11.
 */
public class HotFragment extends Fragment {
    private TabHost mTabHost;
    private FragmentManager fm;
    private Context context;
    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.context = context;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_hot,null);
        View todayView = LayoutInflater.from(context).inflate(R.layout.tab_today, null);
        View weekView = LayoutInflater.from(context).inflate(R.layout.tab_week, null);
        mTabHost = (TabHost) view.findViewById(android.R.id.tabhost);
        mTabHost.setup();
        mTabHost.addTab(mTabHost.newTabSpec("tab1").setIndicator(todayView).setContent(R.id.today));
        mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator(weekView).setContent(R.id.week));
        fm = getActivity().getSupportFragmentManager();
        FragmentTransaction transaction = fm.beginTransaction();
        transaction.replace(R.id.today, new TodayFragment());
        transaction.replace(R.id.week, new WeekFragment());
        transaction.commit();
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }
}
